<?php

namespace App\Http\Services;
/*赠送记录*/
use App\Http\Model\ShareDiamond;
use App\Http\Model\ShareSendGoods;
use App\Http\Model\User;

class ShareDiamondServices extends CommonServices
{
    private $diamond_model;


    public function __construct()
    {
        $this->diamond_model = new ShareDiamond();
    }
        /*
         * 获取赠送记录
         * @param [$user_id]   充值用户
         * @param [$invite_uid]   赠送用户id
         * */
    public function showDiamondLog($user_id,$invite_uid)
    {
        return $this->diamond_model->showDiamondLog($user_id,$invite_uid);
    }


    /*
     * 添加记录
     *  @param [$user_id]   用户id
     *  @param [$invite_uid]   邀请用户id  上级or上上级
     *  @param [$d_rank]    1上级 2上上级
     *  @param [$recharge_money]    充值金额
     *  @param [$diamond_num]    充值钻石
     *  @param [$award_diamond]    奖励钻石
     * */
    public function createDiamond($user_id,$invite_uid,$d_rank,$recharge_money,$diamond_num,$award_diamond)
    {
        $data['user_id'] = $user_id;
        $data['invite_uid'] = $invite_uid;
        $data['d_rank'] = $d_rank;
        $data['recharge_money'] = $recharge_money;
        $data['recharge_diamond'] = $diamond_num;
        $data['award_diamond'] = $award_diamond;
        return $this->diamond_model->createDiamond($data);
    }

    /*
         * 获取用户充值累计
         * @param [$user_id]   用户id
         * */
    public function accumulateLog($user_id)
    {
        return $this->diamond_model->countUserMoney($user_id);
    }

    /*
     * 获取用户是否充值
     * @param [$user_id]   用户id
     * */
    public function showUserRechargeLog($user_id)
    {
        $data =  $this->diamond_model->showUserRecharge($user_id);
        if(count($data) == 0)
            return true;
        return false;
    }

    /*
         * 查看用户充值人数
         * @param [$user_ids]   用户id
         * */
    public function getUserMoney($user_ids)
    {
        $data =  $this->diamond_model->getUserMoneyCount($user_ids);
        if(empty($data))
            return 0;
        foreach($data as $v){
            $count[$v['user_id']] = $v;
        }
        return count($count);
    }
}